﻿using System.Reflection.Emit;
using UnityEngine;

public enum BundleType
{
    Model,
    MAX,
}

public class AssetBundleTargetInfo
{
    public BundleType Type;
    // Name
    public string ShowName;
    // 目标路径
    public string AssetPath;
    //是否分析依赖项
    public bool NeedCheckDependency;
}

public static class AssetBundleConfig
{
    //输出后缀
    public const string ConstAssetTail = ".unity3d";

    //输出路径
    private static readonly string AssetBundleOutFolderName ="AssetBundle";

    //目标资源配置
    private static readonly AssetBundleTargetInfo[] mAssetBundleTargetInfos =
    {
        new AssetBundleTargetInfo
        {
            Type = BundleType.Model ,
            ShowName  =  "Models" ,
            AssetPath =  "Resources/Model" ,
            NeedCheckDependency = false ,
        } ,
    };

    public static AssetBundleTargetInfo[] GetTargetInfos()
    {
        return mAssetBundleTargetInfos;
    }

    public static string GetOutputPath()
    {
        return Application.dataPath + "/StreamingAssets/" + AssetBundleOutFolderName;
    }

    public static string GetAssetsBasePath(bool isSync = false)
    {
        string path = GetAssetBundlePrefix(isSync) + "/" + AssetBundleOutFolderName + "/";
        return path;
    }

    public static AssetBundleTargetInfo GetTypeTargetInfo(BundleType type)
    {
        return mAssetBundleTargetInfos[(int) type];
    }

    public static string GetManitestName()
    {
        return AssetBundleOutFolderName;
    }

    //todo
    static string GetAssetBundlePrefix(bool isSnyc)
    {
        if (!isSnyc)
        {
            return  "file://" + Application.streamingAssetsPath;
        }
        else
        {
            return Application.streamingAssetsPath;
        }
    }
}

